<template>
  <div id="app">
    <router-view />
    <el-backtop :visibility-height="320" :right="40" :bottom="40"></el-backtop>
  </div>
</template>

<script>
import { mapActions } from "vuex";
import { NAV_TABS, NAV_CURRENT_TAB } from "@/configs/keys";
import { SET_TAB_LIST, SET_CURRENT_TAB } from "@/store/tabs/actionTypes";
import { getLocalStorage } from "@/libs/utils";

export default {
  name: "App",
  mounted() {
    this.getLocalNavTabs();
    this.setLocalCrtTab();
  },
  methods: {
    ...mapActions("tabs", [SET_TAB_LIST, SET_CURRENT_TAB]),
    ...mapActions("user", []),

    getLocalNavTabs() {
      const localTabs = getLocalStorage(NAV_TABS);
      if (localTabs) {
        this[SET_TAB_LIST](localTabs);
      }
    },
    setLocalCrtTab() {
      const localCrtTab = getLocalStorage(NAV_CURRENT_TAB);
      if (localCrtTab) {
        this[SET_CURRENT_TAB](localCrtTab);
      }
    },
  },
};
</script>
